/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.CES.connections;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Artem
 */
public class ConnectionManager {

    private static ConnectionManager instance;
    private static final ConnectionPool CONNECTIONPOOL = new ConnectionPool();
    
    private ConnectionManager(){}

    public Connection getConnection() {
        Connection con=null;
        try {
            con= CONNECTIONPOOL.getConnection();
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        return con;
    }

    public void freeConnection(Connection con) {
        CONNECTIONPOOL.free(con);
    }

    public static ConnectionManager getInstance() {
        if (instance == null) {
            instance = new ConnectionManager();
        }
        return instance;
    }
}
